{{--@section('after-scripts-end')--}}
<script>
    $('#base-form').ajaxForm({
        success: function (result) {
            if (result.status) {
                swal({
                    title: "保存成功！",
                    text: "",
                    type: "success"
                }, function () {
                    location = '{{route('admin.supplier.index')}}';
                });
            } else {
                swal('保存失败', result.message, 'error');
            }
        }
    });
    $(function () {
        var uploader = WebUploader.create({
            auto: true,
            swf: '{{url(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
            server: '{{route('file.upload',['_token'=>csrf_token()])}}',
            pick: '#company_license',
            fileVal: 'file',
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            }
        });

        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on('uploadSuccess', function (file, response) {
            var img_url = response.url;
            $('input[name="company_license"]').val(img_url);
            $('.company_license').attr('src', img_url);
        });

        var permitUploader = WebUploader.create({
            auto: true,
            swf: '{{url(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
            server: '{{route('file.upload',['_token'=>csrf_token()])}}',
            pick: '#company_permit',
            fileVal: 'file',
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            }
        });

        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        permitUploader.on('uploadSuccess', function (file, response) {
            var img_url = response.url;
            $('input[name="company_permit"]').val(img_url);
            $('.company_permit').attr('src', img_url);
        });
    });
</script>

{{--@stop--}}